package com.woniu.map.service.impl;

import com.woniu.internalcommon.constant.CommonStatusEnum;
import com.woniu.internalcommon.dto.ResponseResult;
import com.woniu.internalcommon.request.POIRequestDTO;
import com.woniu.internalcommon.response.POIResponse;
import com.woniu.map.remote.POISearchClient;
import com.woniu.map.service.POISearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class POISearchImpl implements POISearchService {
    @Autowired
    private POISearchClient poiSearchClient;

    /**
     *
     * 周边搜索
     * @param poiRequestDTO location 经度,纬度
     * @return
     */
    @Override
    public ResponseResult<POIResponse> aroundPOISearch(POIRequestDTO poiRequestDTO) {
        log.info("POI周边搜索参数："+poiRequestDTO);
        try {
          return ResponseResult.success(poiSearchClient.aroundPOISearch(poiRequestDTO));
        }catch (Exception e) {
            log.error("aroundPOISearch error:"+e.getMessage());
            return ResponseResult.fail(e.getMessage()).
                    setCode(CommonStatusEnum.MAP_DISTRICT_ERROR.getCode());
        }

    }
}
